package net.dgg.zz.credential.qualification.controller;

import net.dgg.framework.tac.utils.bean.DggRestResponse;
import net.dgg.framework.tac.utils.web.commmon.DggBaseController;
import net.dgg.tmd.foundation.platform.org.service.OrganizationManager;
import net.dgg.tmd.foundation.platform.session.SessionManager;
import net.dgg.zz.common.constant.CredentialConstant;
import net.dgg.zz.common.utils.DateUtils;
import net.dgg.zz.credential.qualification.service.QualificationService;
import net.dgg.zz.credential.storageCapacity.service.StorageCapacityService;
import net.dgg.zz.credential.warningConfigure.service.SystemConfigureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.Map;

/**
 * 资质总览
 */
@Controller
@RequestMapping("/zs/credential/pandect")
public class PandectController extends DggBaseController {
    @Autowired
    private SessionManager sessionManager;

    @Autowired
    private OrganizationManager organizationManager;

    @Autowired
    StorageCapacityService storageCapacityService;

    @Autowired
    private SystemConfigureService systemConfigureService;
    @Autowired
    private QualificationService qualificationService;

    @RequestMapping("index")
    public String index(Model model){
        model.addAttribute("generalType", CredentialConstant.ZZ_CREDENTIAL);
        model.addAttribute("overdueStatus", CredentialConstant.CERTIFICATE_APTITUDE_EXCEED_TWO);
        model.addAttribute("LOCAL", CredentialConstant.LOCAL);
        model.addAttribute("NATIONWIDE", CredentialConstant.NATIONWIDE);
        model.addAttribute("certificateStatus", CredentialConstant.CERTIFICATE_APTITUDE_STATUS_TWO);
        model.addAttribute("systemDate",DateUtils.dateString(new Date(),DateUtils.yyyy_MM_dd));
        return "zzsc/credential/qualification/pandect";
    }

    /*
     * @Author zsx
     * @Date 2018-09-13 06:09:05
     * @Description 统计资质总量数据
     * @param param
     * @return DggRestResponse
     */
    @RequestMapping("/get_count_staleTotal")
    @ResponseBody
    public DggRestResponse getCountStaleTotal(@RequestParam Map param){
        try {
            Map count = qualificationService.findAptitudecount(param);
            return this.getSuccessResponse(count);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage(), e);
            return this.getFailResponse("系统错误，请联系管理员");
        }

//        return this.getSuccessResponse("");
    }


}
